<?php
class TDBCommon
{
	const CONF = 'TDBConf';

	private $instance;

	public function __construct(){
		if(!class_exists(CONF)){
			throw new Exception('DB Config error', 20);
		}
		$this->getConnection();
	}

	public function getConnection(){
		$dsn  = $this->getDSN();
		$user = self::CONF::DB_USER;
		$pass = self::CONF::DB_PASS;
		if(!isset(self::$instance)){
			self::$instance = new PDO($dsn, $user, $pass);
		}
	}

	/* Override */
	protected function getDSN(){
		throw new Exception('Setting DSN error', 21);
	}
}
